package com.exam.api.common.utils;

import cn.hutool.poi.excel.ExcelWriter;

import java.io.OutputStream;
import java.util.List;
import java.util.Map;

/**
 * @Author Bcheng
 * @Create 2022/2/9
 * @Description Excel工具类,不建议直接使用index直接操作sheet，在wps/excel中sheet显示顺序与index无关，还有隐藏sheet
 */
public class ExcelUtil extends cn.hutool.poi.excel.ExcelUtil {

    /**
     *  Map<String, Object> map = new HashMap<>();
     *  map.put("订单编号", vo.getOrderNo());
     *  map.put("完成时间", vo.getFinishTime());
     *  map.put("产品名称", vo.getProductName());
     *
     *  List<Map<String, Object>> mapList = ListUtil.of(map)
     *
     * @param mapList
     */
    public static void export(List<Map<String, Object>> mapList, OutputStream out) {
        ExcelWriter writer = cn.hutool.poi.excel.ExcelUtil.getWriter();
        writer.write(mapList, true);
        writer.flush(out);
        writer.close();
    }
}
